home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Almathera Ten Pack 3: CDPD 3
/
Almathera Ten on Ten - Disc 3: CDPD3.iso
/
scope
/
026-050
/
scopedisk29
/
xicon2
/
docfiles
/
manual
< prev
next >
Wrap
Text File
|
1995-03-18
|
21KB
|
446 lines
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 12 May 1987
XICON -- Execute Command File from an Icon
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Copyright (c) 1986, 1987 by Pete Goodeve -- All Rights Reserved
Permission is granted to distribute or modify these programs freely,
provided that no charge is made for their use, and that this notice
accompanies them. For any commercial purposes, please contact the
author:
Pete Goodeve
3012 Deakin Street #D
Berkeley, Calif. 94705
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
With this program you can execute a file of AmigaDOS CLI commands
directly from a WorkBench window, rather than from the CLI, simply by
double-clicking an associated icon in the window. A full-screen window
will be opened to display the output of the commands.
This is a second release of XICON, with many added features. You can
now do such things as specify the size of the window (or run without
any window at all), change the title of the window, find the directory
(drawer) the icon was invoked from, and specify other command scripts
besides the one associated with the icon. You now also get a Close Gadget
on the window.
The little text-display program TICON, which was included in the first
release, is now incorporated -- with improvements -- in XICON itself.
(Though for comprehensive display of text there are many better programs
now available; for example 'more' -- included on the 1.2 Enhancer --
can be invoked from a project icon in just the same way as XICON; others
such as 'less' and 'Blitz' which are commonly available can of course be
executed as CLI commands from XICON). Any simple text file may be used,
provided it is sensibly formatted (with newlines in the right places).
The straightforward use of XICON is to have a 'project' type icon
associated with a file of CLI commands (a "script"): when you double-click
on the icon the commands in the file will be executed. A full-screen
window is opened to display their output. The window will remain open when
the script is finished until you either click on the Close gadget or type
a control-C (or -D).
Many changes can be rung on this basic behavior by adding "Tool Types"
to the icon's info. For example, the window can be configured to
close automatically by setting the ToolType 'MODE=closewindow' in the
icon. If none of the commands have any output that you need to see,
set it to "'MODE=nowindow' and the program will not bother to open a
window at all (any output is just thrown away).
To set the size of the window that will be opened, use the Tool
Type 'WINDOW=...'. To change its title at any point in the sequence,
use 'TITLE=...'. (These options and all the others are described in
detail in their own sections below.)
You also have the option of executing commands from the ToolTypes lines
of the icon itself, if you specify them with the 'CMD=...' ToolType.
(There are advantages and disadvantages to this.) You can specify
additional command scripts (which will be executed before the one
associated with the icon) with 'SCRIPT=...'. You can include a remark
to be displayed in the window with 'REM=...', or a text file with
'TEXT=...'. You can include as many instances of these particular Tool
Types as you like (unlike configuration settings such as 'MODE' or
'WINDOW'); they are processed in sequence. The sequence may include
a wait for a signal from the user with 'PAUSE'.
The icon you click on must always have a file associated with it in order
to keep WorkBench happy, but this needn't NECESSARILY be a list of CLI
commands; if you set 'MODE=noscript' it can be any type of data; you can
operate on it if you want with commands in the ToolTypes list. If you set
'MODE=text' it will be treated as a simple text file to be displayed a
page at a time in the window. This replaces the original separate
program 'TICON'.
The Tool Type 'LOCDIR=..' lets you specify a file in a known place
(probably RAM:) that will be written with the complete pathname of the
directory containing the icon, so you can overcome the defect in DOS
that loses this information.
A very primitive 'choice' mechanism has been added to this version, to
ease the pain of not being able to use DOS conditional commands (IF, etc.)
in the command scripts. You can take special action if the sequence has
been aborted (except when you cut a test display short) -- see the
description of the 'ABORT-...' Tool Types below. You can also use the
'EXISTS=...' Tool Type to see if a file exists, and abort if it doesn't.
You can select more than one icon at a time if you like, by holding down
the Shift key as you click on each. Only DOUBLE-click on the LAST selection
(or use the "Open" item in the WorkBench Menu -- see "Introduction to
Amiga").
Text Display: When XICON is in the text display mode ('MODE=text' or
'TEXT=...') the file is displayed a window-full at a time,
assuming a full screen window. It will also pause if a form-feed character
is encountered. To continue, type any key or click in the bottom border
of the window. You can abort display of that file by either clicking in
the Close gadget or typing control-C; it will immediately proceed to the
next operation if any. You will have to repeat the action to exit XICON
if there are no more operations. Note that this is different from the
immediate exit that follows a click on the Close gadget in reponse to
a PAUSE Tool Type.
Setup: You can install Xicon itself in any convenient directory: you
could use either the 'C:' directory of your Workbench disk
or a directory on the same disk as the icons. (It doesn't need an icon
of its own.) Whichever directory you use, the icons that are going to
invoke it must have a matching pathname as their DEFAULT TOOL (see below).
You can put an icon and its associated file in any directory ("drawer")
that you can open under WorkBench. The file must of course have the same
name as the icon (without the '.info' extension the icon has tacked on).
Each icon must be of type 'PROJECT' with a DEFAULT TOOL string specifying
a path to the Xicon program. If it is in the same directory, 'xicon' will
suffice, otherwise you must use the complete pathname. A full pathname
always begins with the "device name", which is either an actual device
(e.g. DF0: or RAM:) or an assigned name (e.g. SYS: or C:). (See the DOS
manual.) If the icons are on the same disk as xicon, the device can be
simply ":" (the colon character alone); for example, if the program
'xicon' is in the directory 'xicon' on the same disk as the icon,
the default tool pathname would be:
:XICON/XICON
Command Scripts: There are many ways to generate Command Script files
with their icons. One simple approach is to duplicate
the "democommand" supplied and rename it (using WorkBench Menu operations),
then go to the CLI and modify the text file using whatever editor you are
comfortable with. If xicon is not in the appropriate directory, you will
also have to change the Default Tool in the icon to the correct pathname
(see below for how to do this).
Alternatively you can create the text file first (let's call it 'myscript'),
then use the CLI to copy a suitable project icon ('democommand.info' for
instance) to 'myscript.info' and modify it as necessary.
Modifying an icon: All the changes you should need to make to an icon
(except change its appearance! -- the Icon Editor
is one way of doing that) can be done with the 'Info' item in the WorkBench
Menu. Select the icon you want to modify by clicking on it, depress the
right mouse button to bring up the menu, and select 'Info' from the
'WorkBench' section. This should bring up an information window for
that icon.
To set the DEFAULT TOOL, click in that gadget and type in (or edit) the
string.
To enter a new TOOL TYPE, click first on the ADD gadget, then click in the
string gadget and type it in. If you want to insert it into an existing
set, use the arrow gadgets on the left to move to the desired point first.
You can of course edit the strings in the usual way. Use the DEL gadget
to remove a line completely.
When you are done, click in the SAVE box to preserve the changes.
Note that there is a highly annoying bug in the current release of
WorkBench: very often the set of Tool Types you enter into the icon
gets screwed up -- apparently the string terminator gets lost on some
entries, causing the next string to be tagged on. I haven't established
the exact circumstances, but the only fix seems to be to go back to the
Info, re-edit all your Tool Types, and try saving again. Eventually
this should work.
MODE Setting: You can alter the assumptions made by Xicon by setting the
Tool Type 'MODE'.
'MODE=closewindow' avoids having to use control-C or the Close
gadget to terminate the program. The window will close as soon
as all the commands have completed.
'MODE=nowindow' tells XICON not to open any window at all. Any
output from executing commands is simply thrown away (sent to NIL:).
'MODE=noscript' prevents Xicon from trying to read commands from
its associated file, so this can be of any type. This option only
makes sense if the 'CMD=' Tool Type is used to supply the commands.
'MODE=text' indicates that the associated file is text, and should
be displayed a window-full at a time.
Only one MODE entry will be recognized in the Tool Types array, so if you
want more than one of the above options, you must specify them separated
by the vertical-bar character, for example: 'MODE=noscript|closewindow'.
Modifying the Window: You can specify the size, position and title of
the window that XICON opens by setting the
Tool Type 'WINDOW=xxx/yyy/www/hhh/Title', where xxx and yyy are the
co-ordinates of the top left corner, www and hhh are width and height,
and Title is the desired name for the window. In other words this is
just the string you would use to specify a 'CON:' window from the CLI,
WITHOUT the 'CON:' prefix itself.
You can't change the size or position of the window once it has
been opened, but you can change its title. Just include the Tool Type
'TITLE=title string'. You can use this more than once in a sequence
(of Tool Type commands -- see below) if you want.
Commands in the Icon: Instead of a script file, you can specify commands
directly in the Tool Types array of the icon, with
the 'CMD=command string' format. (For example: 'CMD=list df1:work'.)
Include as many of these as you like. They will be executed in sequence,
but each by a separate CLI process, so you can't use a command to set
parameters like stack size or current directory for the ones that follow.
A Command Script file on the other hand is executed completely by one
process, so settings are inherited.
If you want to execute additional command script files before the one
associated with the icon (if any), use 'SCRIPT=filename'. As usual,
'filename' may either be the name of a script file in the same directory
as the icon, or it may be the complete pathname of such a file. These
lines may be interspersed with 'CMD=..' lines (or others) and will be
taken in their turn. Again, each 'SCRIPT=..' is handled by a separate
CLI process.
Finding the Directory: An unfortunate problem of executing commands
in this fashion is that the new CLI has no
idea of which directory it was called from. To overcome this, XICON
has the Tool Type 'LOCDIR=filename'. If you include this in the icon,
the specified file will be created and filled with a text string giving
the complete path name of the directory containing the icon. Commands
in the script can refer to this file -- which should be in a known place
such as RAM: -- to take appropriate action. The string is always enclosed
in quotes, and has a newline character at the end. DOS commands such
as CD or DIR can read this string simply by redirecting their input and
prompting with '?' (for commands like CD which don't have any needed
output you can suppress the prompt by redirecting output to NIL:).
For example, include in the icon info:
LOCDIR=RAM:my_icon_dir
then start your script with the sequence:
CD <RAM:my_icon_dir >NIL: ?
and you are now working in the right directory. For neatness, you should
also delete the file before you end the command script. It is best to
choose unique file names if you are likely to be running more than one
icon at a time.
Other Tool Types: You have various other actions that you can
request with Tool Type strings. They may be
intermixed with the previous types.
'TEXT=filename' displays the specified file in the window, in
the same way that 'MODE=text' does for the main file.
'REM=text' displays the text line as a remark at that point.
'PAUSE' (Note -- no "="!) pauses the sequence at that point,
as if a form-feed had been encountered in a text file.
Continue by clicking in the bottom border of the window or
typing any key. If you click in the Close gadget instead,
or type control-C, all remaining Tool Type commands will be
skipped except 'RESTORE' and those with the 'ABORT-' prefix.
'RESTORE' is only relevant if the sequence has been aborted.
If it is is encountered it removes the abort condition;
Tool Type commands and the file associated with the icon
will be executed as normal.
'EXISTS=filename' will set the abort condition (as if the Close
gadget had been clicked or control-C typed) if the specified
file doesn't exist.
The 'abort' condition: If the Close gadget is clicked or control-C
typed in response to a PAUSE, or if an
'EXISTS=...' Tool Type fails, the abort condition will be set;
all further normal Tool Type commands, and execution or display of
the file associated with the icon, will be suppressed. If the 'RESTORE'
Tool Type is encountered, however, normal operation will be restored.
There are a set of alternative Tool Type commands, corresponding to
the normal ones but prefixed with 'ABORT-', that will ONLY be executed
if the abort condition has been set. The set is:
ABORT-REM=...
ABORT-CMD=...
ABORT-TEXT=...
ABORT-SCRIPT=...
ABORT-PAUSE
Note that the last one behaves JUST like normal PAUSE -- in other words
if you click in the Continue gadget or type a key other than control-C
the abort condition is REMOVED.
Sequence of Tool Types: Remember the difference between the Tool Types
that control the environment ('MODE=...',
'WINDOW=...', etc.) and those that are scanned in sequence. The first
appearance of each of the former will be recognized at startup -- and at
startup only -- so they won't for example be affected by an abort condition.
They may actually be placed anywhere in the set of Tool Types, in any order,
and they will still be recognized.
The Tool Types processed at startup are:
MODE=
WINDOW=
LOCDIR=
Those processed in sequence are:
CMD=
REM=
SCRIPT=
TEXT=
TITLE=
PAUSE
RESTORE
EXISTS=
ABORT-...
If you misspell a Tool Type name, it will simply be ignored.
Caveats:
An annoying defect is that the "Execute()" system call used by xicon
loses track of the current directory when invoked by a WorkBench
program (it switches to DF0:). The LOCDIR Tool Type has been added to
overcome this problem, but if you don't use this you will have to
specify full pathnames.
The "Execute" referred to above is NOT the DOS "EXECUTE" Command, by
the way, in case anyone is confused. Actually this system call (and
therefore xicon) requires the DOS "RUN" command -- which must be
available in the "C:" directory -- for its operation. (Now I'll bet
you're confused again...)
Because xicon's method of calling Execute() sets up the command
file as the input stream, the output window cannot be used as a
console. So if a command needs keyboard input it must open up its own
console window using I/O redirection, e.g.:
mycommand <CON:0/100/150/50/input
(It would likely be a program of your own, because DOS commands don't
usually ask for input, unless you use the "?" option in the command
line. Although, for an example, see the "Set Date" command file in this
directory.) You might also want to try "EXECUTE CON:0/100/150/50/exec"
--or whatever you have renamed that command as. (To get out of the
mini-CLI you just created, use 'control-\'.) If you really want to
create a full new CLI, the best method is 'NEWCLI FROM filename'
-- see the 1.2 Enhancer Manual.
By the way, this release of xicon is SUPPOSED to be compatible with
WorkBench 1.1, but I'm afraid I've only really checked it briefly...
The initial stack size is always 4000 bytes. You can change this in
your command script with a suitable STACK command. Note that the
STACK gadget in the icon Info window does not have any effect. (Except
on the stack used by Xicon itself! I haven't investigated how much
it needs.)
You cannot interrupt a command sequence with control-C or control-D
(because the input stream has been diverted), although output can be
paused with the space bar in the usual way. Be careful not to write
a command file that can get "stuck", or you will never be able to
close that window.
Unfortunately DOS won't let you use IF, SKIP, QUIT, and so on in
these command files. Of course you can use EXECUTE on a subsidiary
script file; alternatively 'NEWCLI FROM scriptfile' also allows
conditional commands.
You can use the RUN command from a command script, of course, but
-- unlike when it is invoked from the CLI -- any output from the
process started by RUN that you would expect to see on the screen
is instead thrown away.
%%%%%%%%%%%%%%%%
Coda
I hope you find these programs useful. If you do, please pass them around
freely. I'm not asking any specific contribution for this program, but if
you find it useful -- and approve of the Shareware concept -- I would be
pleased no end if you decided to send me $5 or $10 (my address is in the
copyright notice at the top). I'm also glad to get comments -- positive
OR negative.
I suggest you copy the entire drawer -- with its demo and source
files -- by dragging its icon to another disk. (You won't see either the
programs or their sources in the WorkBench window; they don't have icons.
You can only get at them using the CLI.)
If you use the CLI and are fed up with its limitations (no cursor editing,
having to use EXECUTE for command scripts and so on) you might be interested
in a true ShareWare product of mine. I'm asking $25 if you use it, but
for that you get support -- by mail -- and an update when the next version
now in development is ready.
It's a Smart Input Line Interpreter called "Sili(Con:)", and for a start
it lets you enter your commands with full cursor editing facilities.
In addition, previous commands are kept in a VISIBLE history list; you
can recall commands from this list for re-execution and/or re-editing,
either by moving through the list with the up and down arrow keys or
directly by clicking on them with the mouse. All this takes place in
a window completely separate from the normal Console window where you
see the command output and interact with the programs you invoke; you
can be entering and editing commands while previous ones are chugging
away in the main window. Real MultiTasking! If you have a set of
commands you are using repetively, you can invoke them directly from
the history window by double-clicking on them with the mouse. When you
need to you can push the command window out of the way or bring it back
with a single keystroke. Also of course you can invoke command scripts
without typing EXECUTE (or your usual abbreviated equivalent!).
If you are interested in Sili(Con:), it is available from many sources.
It is downloadable from several of the commercial data services, and is
on disks from users groups and distributors of Public Domain software
and ShareWare such as Fred Fish (disk #50 in his case). If all else
fails, you can order it directly, for $25 plus $3 p&p (Calif. residents
add 6.5% sales tax) from
Winners Circle Systems
2618 Telegraph Avenue
Berkeley, California 94704
[Tel: (415) 845-4814]
##############